﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Iacym.Entities;

namespace Iacym.Repository
{
    public class MenuRepository:MasterRepository,IMenuRepository
    {

        /*metodo para mostrar las pestañas generales del menu*/
        public List<Entities.MENU> GetAllMenu()
        {
            var query = from m in context.MENUs
                        where m.Tag == 1000 || m.Tag == 2000 || m.Tag == 3000 || m.Tag == 4000 || m.Tag == 5000 || m.Tag == 6000
                        select m;
            return query.ToList();
        }


        /*metodo para avanzar a las sub pestañas del menu general*/
        public List<MENU> GetAllFromMenuByTag(int tag)
        {
            if (tag == 1000)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1005 || m.Tag == 1010 || m.Tag == 1015 || m.Tag == 1020 || m.Tag == 1025 || m.Tag == 1030 || m.Tag == 1035 || m.Tag == 1040 ||
                                      m.Tag == 1045 || m.Tag == 1050 || m.Tag == 1055 || m.Tag == 1060 || m.Tag == 1065 || m.Tag == 1070 || m.Tag == 1075 || m.Tag == 1080 ||
                                      m.Tag == 1085 || m.Tag == 1090 || m.Tag == 1095
                            select m;
                return query.ToList();
            }
            else if (tag == 2000)
            {
                var query = from m in context.MENUs
                            where m.Tag == 2005 || m.Tag == 2010 || m.Tag == 2015 || m.Tag == 2020
                            select m;
                return query.ToList();
            }
            else if (tag == 3000)
            {
                var query = from m in context.MENUs
                            where m.Tag == 3005
                            select m;
                return query.ToList();
            }
            else if (tag == 4000)
            {
                var query = from m in context.MENUs
                            where m.Tag == 4005 || m.Tag == 4010
                            select m;
                return query.ToList();
            }
            else if (tag == 5000)
            {
                var query = from m in context.MENUs
                            where m.Tag == 5005
                            select m;
                return query.ToList();
            }
            else if (tag == 6000)
            {
                var query = from m in context.MENUs
                            where m.Tag == 6005 || m.Tag == 6010
                            select m;
                return query.ToList();
            }
            else
            {
                var query = from m in context.MENUs
                            where m.Tag == null
                            select m;
                return query.ToList();
            }
        }


        /*metodo para avanzar a los detalles de cada pestaña del menu*/
        public List<MENU> GetAllFromMenuByMantenimientoByTag(int tag)
        {
            if (tag == 1005)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1006 || m.Tag == 1007 || m.Tag == 1008 || m.Tag == 1009
                            select m;
                return query.ToList();
            }
            else if (tag == 1010)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1011 || m.Tag == 1012 || m.Tag == 1013 || m.Tag == 1014
                            select m;
                return query.ToList();
            }
            else if (tag == 1015)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1016 || m.Tag == 1017 || m.Tag == 1018 || m.Tag == 1019
                            select m;
                return query.ToList();
            }
            else if (tag == 1020)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1021 || m.Tag == 1022 || m.Tag == 1023 || m.Tag == 1024
                            select m;
                return query.ToList();
            }
            else if (tag == 1025)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1026 || m.Tag == 1027 || m.Tag == 1028 || m.Tag == 1029
                            select m;
                return query.ToList();
            }
            else if (tag == 1030)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1031 || m.Tag == 1032 || m.Tag == 1033 || m.Tag == 1034
                            select m;
                return query.ToList();
            }
            else if (tag == 1035)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1036 || m.Tag == 1037 || m.Tag == 1038 || m.Tag == 1039
                            select m;
                return query.ToList();
            }
            else if (tag == 1040)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1041 || m.Tag == 1042 || m.Tag == 1043 || m.Tag == 1044
                            select m;
                return query.ToList();
            }
            else if (tag == 1045)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1046 || m.Tag == 1047 || m.Tag == 1048 || m.Tag == 1049
                            select m;
                return query.ToList();
            }
            else if (tag == 1050)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1051 || m.Tag == 1052 || m.Tag == 1053 || m.Tag == 1054
                            select m;
                return query.ToList();
            }
            else if (tag == 1055)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1056 || m.Tag == 1057 || m.Tag == 1058 || m.Tag == 1059
                            select m;
                return query.ToList();
            }
            else if (tag == 1060)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1061 || m.Tag == 1062 || m.Tag == 1063 || m.Tag == 1064
                            select m;
                return query.ToList();
            }
            else if (tag == 1065)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1066 || m.Tag == 1067 || m.Tag == 1068 || m.Tag == 1069
                            select m;
                return query.ToList();
            }
            else if (tag == 1070)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1071 || m.Tag == 1072 || m.Tag == 1073 || m.Tag == 1074
                            select m;
                return query.ToList();
            }
            else if (tag == 1075)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1076 || m.Tag == 1077 || m.Tag == 1078 || m.Tag == 1079
                            select m;
                return query.ToList();
            }
            else if (tag == 1080)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1081 || m.Tag == 1082 || m.Tag == 1083 || m.Tag == 1084
                            select m;
                return query.ToList();
            }
            else if (tag == 1085)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1086 || m.Tag == 1087 || m.Tag == 1088 || m.Tag == 1089
                            select m;
                return query.ToList();
            }
            else if (tag == 1090)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1091 || m.Tag == 1092 || m.Tag == 1093 || m.Tag == 1094
                            select m;
                return query.ToList();
            }
            else if (tag == 1095)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1096 || m.Tag == 1097 || m.Tag == 1098 || m.Tag == 1099
                            select m;
                return query.ToList();
            }
            else if (tag == 2005)
            {
                var query = from m in context.MENUs
                            where m.Tag == 2006 || m.Tag == 2007 || m.Tag == 2008 || m.Tag == 2009
                            select m;
                return query.ToList();
            }
            else if (tag == 2010)
            {
                var query = from m in context.MENUs
                            where m.Tag == 2011 || m.Tag == 2012 || m.Tag == 2013 || m.Tag == 2014
                            select m;
                return query.ToList();
            }
            else if (tag == 2015)
            {
                var query = from m in context.MENUs
                            where m.Tag == 2016 || m.Tag == 2017 || m.Tag == 2018 || m.Tag == 2019
                            select m;
                return query.ToList();
            }
            else if (tag == 2020)
            {
                var query = from m in context.MENUs
                            where m.Tag == 2021 || m.Tag == 2022 || m.Tag == 2023 || m.Tag == 2024
                            select m;
                return query.ToList();
            }
            else if (tag == 3005)
            {
                var query = from m in context.MENUs
                            where m.Tag == 3006 || m.Tag == 3007 || m.Tag == 3008 || m.Tag == 3009
                            select m;
                return query.ToList();
            }
            else if (tag == 4005)
            {
                var query = from m in context.MENUs
                            where m.Tag == 4006 || m.Tag == 4007 || m.Tag == 4008 || m.Tag == 4009
                            select m;
                return query.ToList();
            }
            else if (tag == 4010)
            {
                var query = from m in context.MENUs
                            where m.Tag == 4011 || m.Tag == 4012 || m.Tag == 4013 || m.Tag == 4014
                            select m;
                return query.ToList();
            }
            else if (tag == 5005)
            {
                var query = from m in context.MENUs
                            where m.Tag == 5006 || m.Tag == 5007 || m.Tag == 5008 || m.Tag == 5009
                            select m;
                return query.ToList();
            }
            else if (tag == 6005)
            {
                var query = from m in context.MENUs
                            where m.Tag == 6006 || m.Tag == 6007 || m.Tag == 6008 || m.Tag == 6009
                            select m;
                return query.ToList();
            }
            else if (tag == 6010)
            {
                var query = from m in context.MENUs
                            where m.Tag == 6011 || m.Tag == 6012 || m.Tag == 6013 || m.Tag == 6014
                            select m;
                return query.ToList();
            }
            else
            {
                var query = from m in context.MENUs
                            where m.Tag == null
                            select m;
                return query.ToList();
            }
        }


        /*metodo para retroceder en la buskeda del menu*/
        public List<MENU> GetAllFromMenuByMantenimientoByTagByReturn(int tag)
        {
            if (tag == 1006 || tag == 1007 || tag == 1008 || tag == 1009 || tag == 1011 || tag == 1012 || tag == 1013 || tag == 1014 ||
               tag == 1016 || tag == 1017 || tag == 1018 || tag == 1019 || tag == 1021 || tag == 1022 || tag == 1023 || tag == 1024 ||
               tag == 1026 || tag == 1027 || tag == 1028 || tag == 1029 || tag == 1031 || tag == 1032 || tag == 1033 || tag == 1034 ||
               tag == 1036 || tag == 1037 || tag == 1038 || tag == 1039 || tag == 1041 || tag == 1042 || tag == 1043 || tag == 1044 ||
               tag == 1046 || tag == 1047 || tag == 1048 || tag == 1049 || tag == 1051 || tag == 1052 || tag == 1053 || tag == 1054 ||
               tag == 1056 || tag == 1057 || tag == 1058 || tag == 1059 || tag == 1061 || tag == 1062 || tag == 1063 || tag == 1064 ||
               tag == 1066 || tag == 1067 || tag == 1068 || tag == 1069 || tag == 1071 || tag == 1072 || tag == 1073 || tag == 1074 ||
               tag == 1076 || tag == 1077 || tag == 1078 || tag == 1079 || tag == 1081 || tag == 1082 || tag == 1083 || tag == 1084 ||
               tag == 1086 || tag == 1087 || tag == 1088 || tag == 1089 || tag == 1091 || tag == 1092 || tag == 1093 || tag == 1094 ||
               tag == 1096 || tag == 1097 || tag == 1098 || tag == 1099)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1005 || m.Tag == 1010 || m.Tag == 1015 || m.Tag == 1020 || m.Tag == 1025 || m.Tag == 1030 || m.Tag == 1035 || m.Tag == 1040 ||
                                      m.Tag == 1045 || m.Tag == 1050 || m.Tag == 1055 || m.Tag == 1060 || m.Tag == 1065 || m.Tag == 1070 || m.Tag == 1075 || m.Tag == 1080 ||
                                      m.Tag == 1085 || m.Tag == 1090 || m.Tag == 1095
                            select m;
                return query.ToList();
            }

            else if (tag == 2006 || tag == 2007 || tag == 2008 || tag == 2009 || tag == 2011 || tag == 2012 || tag == 2013 || tag == 2014 ||
                        tag == 2016 || tag == 2017 || tag == 2018 || tag == 2019 || tag == 2021 || tag == 2022 || tag == 2023 || tag == 2024)
            {
                var query = from m in context.MENUs
                            where m.Tag == 2005 || m.Tag == 2010 || m.Tag == 2015 || m.Tag == 2020
                            select m;
                return query.ToList();
            }

            else if (tag == 3006 || tag == 3007 || tag == 3008 || tag == 3009)
            {
                var query = from m in context.MENUs
                            where m.Tag == 3005
                            select m;
                return query.ToList();
            }

            else if (tag == 4006 || tag == 4007 || tag == 4008 || tag == 4009 || tag == 4011 || tag == 4012 || tag == 4013 || tag == 4014)
            {
                var query = from m in context.MENUs
                            where m.Tag == 4005 || m.Tag == 4010
                            select m;
                return query.ToList();
            }

            else if (tag == 5006 || tag == 5007 || tag == 5008 || tag == 5009)
            {
                var query = from m in context.MENUs
                            where m.Tag == 5005
                            select m;
                return query.ToList();
            }

            else if (tag == 6006 || tag == 6007 || tag == 6008 || tag == 6009 || tag == 6011 || tag == 6012 || tag == 6013 || tag == 6014)
            {
                var query = from m in context.MENUs
                            where m.Tag == 6005 || m.Tag == 6010
                            select m;
                return query.ToList();
            }

            else if (tag >= 1005 || tag <= 1065 || tag >= 2005 || tag <= 2015 || tag >= 3005 || tag <= 3010 || tag >= 4005 || tag <= 4010 || tag >= 5005 || tag <= 5010 || tag >= 6005 || tag <= 6010)
            {
                var query = from m in context.MENUs
                            where m.Tag == 1000 || m.Tag == 2000 || m.Tag == 3000 || m.Tag == 4000 || m.Tag == 5000 || m.Tag == 6000
                            select m;
                return query.ToList();
            }
            else
            {
                var query = from m in context.MENUs
                            where m.Tag == null
                            select m;
                return query.ToList();
            }
        }
    }
}
